package com.bluesky.drcp.business.logic;

import java.util.List;

import com.bluesky.drcp.business.Function;
import com.bluesky.drcp.business.Log;
import com.bluesky.drcp.business.Plugin;
import com.bluesky.drcp.business.service.ClientConfigService;
import com.bluesky.drcp.business.service.FunctionAuthorizationService;
import com.bluesky.drcp.business.service.FunctionModuleService;
import com.bluesky.drcp.business.service.FunctionService;
import com.bluesky.drcp.business.service.GlobalVariableService;
import com.bluesky.drcp.business.service.LogService;
import com.bluesky.drcp.business.service.ModuleService;
import com.bluesky.drcp.business.service.PluginService;
import com.bluesky.drcp.business.service.RoleService;
import com.bluesky.drcp.business.service.UserRoleService;
import com.bluesky.drcp.business.service.UserService;

public class DrcpImpl implements DrcpFacade {


	// system
	private LogService logService;

	private ClientConfigService clientConfigService;

	private PluginService pluginService;

	private UserService userService;
	
	private RoleService roleService;
	
	private UserRoleService userRoleService;

	private GlobalVariableService globalVariableService;
	
	// admin
	private FunctionService functionService;

	private ModuleService moduleService;

	private FunctionModuleService functionModuleService;

	private FunctionAuthorizationService functionAuthorizationService;

	
	public List getChildrenFunction(String id) {

		return functionService.getChildren(id);
	}

	
	public Function getParentFunction(String id) {

		return functionService.getParent(id);
	}

	
	public Function getRootFunction() {
		return functionService.getRoot();

	}

	
	public FunctionService getFunctionService() {
		return functionService;
	}

	public void setFunctionService(FunctionService functionService) {
		this.functionService = functionService;
	}

	public String ClientConfig_GetContent(String host, String module) {
		return clientConfigService.getContent(host, module);
	}

	public void ClientConfig_SetContent(String host, String module,
			String content) {

		clientConfigService.setContent(host, module, content);

	}

	public ClientConfigService getClientConfigService() {
		return clientConfigService;
	}

	public void setClientConfigService(ClientConfigService clientConfigService) {
		this.clientConfigService = clientConfigService;
	}

	
	public String getClientConfigContent(String host, String module) {

		return clientConfigService.getContent(host, module);
	}

	public void setClientConfigContent(String host, String module,
			String content) {
		clientConfigService.setContent(host, module, content);

	}

	
	public Plugin getPluginById(String id) {
		return pluginService.get(id);
	}

	public Plugin getPluginByName(String name) {
		return pluginService.getByName(name);
	}

	
	public void insertOrUpdatePluginByName(Plugin o) {

		pluginService.saveOrUpdateByName(o);

	}


	public PluginService getPluginService() {
		return pluginService;
	}

	public void setPluginService(PluginService pluginService) {
		this.pluginService = pluginService;
	}

	public LogService getLogService() {
		return logService;
	}

	public void setLogService(LogService logService) {
		this.logService = logService;
	}

	public void addLog(String userId, String computerName, String source,
			int type, String category, String action, String comment) {

		logService.addLog(userId, computerName, source, type, category,
				action, comment);

	}

	public void addLog(Log o) {
		logService.insert(o);
	}

	public FunctionModuleService getFunctionModuleService() {
		return functionModuleService;
	}

	public ModuleService getModuleService() {
		return moduleService;
	}

	public void setFunctionModuleService(
			FunctionModuleService functionModuleService) {
		this.functionModuleService = functionModuleService;
	}

	public void setModuleService(ModuleService moduleService) {
		this.moduleService = moduleService;
	}

	public FunctionAuthorizationService getFunctionAuthorizationService() {
		return functionAuthorizationService;
	}

	public void setFunctionAuthorizationService(
			FunctionAuthorizationService functionAuthorizationService) {
		this.functionAuthorizationService = functionAuthorizationService;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public GlobalVariableService getGlobalVariableService() {
		return globalVariableService;
	}

	public void setGlobalVariableService(GlobalVariableService globalVariableService) {
		this.globalVariableService = globalVariableService;
	}

	public UserRoleService getUserRoleService() {
		return userRoleService;
	}

	public void setUserRoleService(UserRoleService userRoleService) {
		this.userRoleService = userRoleService;
	}

	public RoleService getRoleService() {
		return roleService;
	}

	public void setRoleService(RoleService roleService) {
		this.roleService = roleService;
	}
	
}
